﻿namespace LeetCodeProject._0001_1000._101_200._111_120._112;

public class Solution
{
    public bool HasPathSum(TreeNode root, int targetSum)
    {
        switch (root)
        {
            case null:
                return false;
            case var _ when root.left == null && root.right == null:
                return root.val == targetSum;
            default:
                return HasPathSum(root.right, 
                    targetSum - root.val) || 
                       HasPathSum(root.left, 
                           targetSum - root.val);
        }
    }
}